// pages/case-info/index.js

var api = require('../../config/api.js');
var util = require('../../utils/util.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    activeName: '1',
    active: 2,
    baseInfo: {},
    steps: [],
    yearFeeList: []
  },
  nextStep() {
    this.setData({
      active: ++this.data.active % 4,
    });
  },
  onChange(event) {
    this.setData({
      activeName: event.detail,
    });
  },
  clickStep() {},

  /** 官文列表跳转 */
  goOfficialList() {
    var that = this;
    wx.navigateTo({
      url: '../offic-doc/index?caseNo=' + that.data.baseInfo.caseNo,
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      baseInfo: {
        caseNo: options.caseNo
      },
    });
    this.getCaseInfo();
    this.getNoticeStepsByCaseNo();
    this.getYearFeeListByCaseNo();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  /** 获取案件详情 */
  getCaseInfo: function () {
    var that = this;
    util.request(api.getCaseInfo, {
      caseNo: that.data.baseInfo.caseNo
    }, 'GET').then(res => {
      if (res.result == 1) {
        that.setData({
          baseInfo: res.info
        });
      }
    });
  },

  /** 获取通知书步骤条数据 */
  getNoticeStepsByCaseNo: function () {
    var that = this;
    util.request(api.getNoticeStepsByCaseNo, {
      caseNo: that.data.baseInfo.caseNo
    }, 'GET').then(res => {
      if (res.result == 1) {
        that.setData({
          steps: res.info,
          active: res.info.length-1
        });
      }
    });
  },

  /** 获取年费表格数据 */
  getYearFeeListByCaseNo: function () {
    var that = this;
    util.request(api.getYearFeeListByCaseNo, {
      caseNo: that.data.baseInfo.caseNo
    }, 'GET').then(res => {
      if (res.result == 1) {
        that.setData({
          yearFeeList: res.info
        });
      }
    });
  }



})